package org.deadline.service.config;

import java.util.List;
import org.deadline.model.config.ApplicationConfiguration;
import org.deadline.repository.config.ApplicationConfigurationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class ApplicationConfigurationServiceImpl implements ApplicationConfigurationService {

	@Autowired
    ApplicationConfigurationRepository applicationConfigurationRepository;

	public long countAllApplicationConfigurations() {
        return applicationConfigurationRepository.count();
    }

	public void deleteApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
        applicationConfigurationRepository.delete(applicationConfiguration);
    }

	public ApplicationConfiguration findApplicationConfiguration(Long id) {
        return applicationConfigurationRepository.findOne(id);
    }

	public List<ApplicationConfiguration> findAllApplicationConfigurations() {
        return applicationConfigurationRepository.findAll();
    }

	public List<ApplicationConfiguration> findApplicationConfigurationEntries(int firstResult, int maxResults) {
        return applicationConfigurationRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
        applicationConfigurationRepository.save(applicationConfiguration);
    }

	public ApplicationConfiguration updateApplicationConfiguration(ApplicationConfiguration applicationConfiguration) {
        return applicationConfigurationRepository.save(applicationConfiguration);
    }
}
